﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ERP.Manager.DataEntity;
using ERP.Manager.SQLServerProvider;
using ERP.Manager.DataProvider;
namespace ERP.Manager.BusinessServices
{
    public class DepartmentServices
    {
        private readonly IDepartmentRepository departmentrepository;
        public DepartmentServices() { }
        public DepartmentServices(IDepartmentRepository DepartmentRepository)
        {
            this.departmentrepository = DepartmentRepository;
        }
        #region 新增部门信息的方法
        public int addDepartment(DepartmentInfo department)
        {
            return departmentrepository.addDepartment(department);
        }
        #endregion

        #region 修改部门信息的方法
        public int UpdateDepartment(DepartmentInfo department)
        {
            return departmentrepository.UpdateDepartment(department);
        }
        #endregion

        #region 根据编号查询部门的详细信息
        public DepartmentInfo DetailDepartment(string departmentid)
        {
            return departmentrepository.DetailDepartment(departmentid);
        }
        #endregion

        #region 根据部门名称查询部门的详细信息
        public DepartmentInfo DetailDepartmentdepartment(string departmentname)
        {
            return departmentrepository.getDepartments().Find(depart => depart.departmentName == departmentname);
        }
        #endregion

        #region 查询所有部门信息的方法
        public List<DepartmentInfo> getDepartments()
        {
            return departmentrepository.getDepartments();
        }
        #endregion
    }
}
